home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / clib / strdup.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  934b  |  58 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: strdup.c,v 1.2 1996/10/19 16:56:29 aros Exp $
  4.  
  5.     Desc: ANSI C function strdup()
  6.     Lang: english
  7. */
  8.  
  9. /*****************************************************************************
  10.  
  11.     NAME */
  12.     #include <string.h>
  13.     #include <memory.h>
  14.  
  15.     char * strdup (
  16.  
  17. /*  SYNOPSIS */
  18.     const char * orig)
  19.  
  20. /*  FUNCTION
  21.     Create a copy of a string. The copy can be freed with free() or will
  22.     be freed when then program ends.
  23.  
  24.     INPUTS
  25.     str1 - Strings to duplicate
  26.  
  27.     RESULT
  28.     A copy of the string which can be freed with free().
  29.  
  30.     NOTES
  31.  
  32.     EXAMPLE
  33.  
  34.     BUGS
  35.  
  36.     SEE ALSO
  37.  
  38.     INTERNALS
  39.  
  40.     HISTORY
  41.     24-12-95    digulla created
  42.  
  43. ******************************************************************************/
  44. {
  45.     char * copy;
  46.     char * ptr;
  47.  
  48.     if ((copy = malloc (strlen (orig)+1)))
  49.     {
  50.     ptr = copy;
  51.  
  52.     while ((*ptr ++ = *orig ++));
  53.     }
  54.  
  55.     return copy;
  56. } /* strdup */
  57.  
  58.